package org.scirp.ijmis.dao.common.impl;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.scirp.ijmis.dao.base.impl.BaseDAOImpl;
import org.scirp.ijmis.dao.common.IResearchFieldDAO;

import org.scirp.ijmis.po.common.ResearchField;

public class ResearchFieldDAOImpl extends BaseDAOImpl<ResearchField> implements IResearchFieldDAO {

	private static final String className = ResearchFieldDAOImpl.class.toString();

	public List<ResearchField> selectAll() {

		String hql="from ResearchField order by researchfield " ;			
		return super.ExecuteQuery(hql, className+"-->selectAll");	
	}

	public ResearchField selectById(Object id) {

		return (ResearchField) super.selectById(id, className + "-->selectById");
	}
public List<ResearchField> selectResearchFieldByJournalId(Long journalId) {
		
		String hql="from ResearchField where journal.pid=:journalId order by researchfield " ;	
		Map<String,Object> map=new HashMap<String, Object>();
		map.put("journalId", journalId);
		return super.ExecuteQuery(hql,map, className+"--> selectResearchFieldByJournalId(Long journalId)");			 
	}	
public List<ResearchField> selectResearchFieldByJournalIdAndResearchField(Long journalId,String researchfield) {
	
	String hql="from ResearchField where journal.pid=:journalId and  lower(trim(researchfield))=lower(trim(:researchfield))" ;	
	Map<String,Object> map=new HashMap<String, Object>();
	map.put("journalId", journalId);
	map.put("researchfield", researchfield);
	return super.ExecuteQuery(hql,map, className+"--> selectResearchFieldByJournalId(Long journalId)");			 
}	
	public List<ResearchField> selectByJournalId(long id) {
		String hql = "from ResearchField where journalId=" + id+" order by researchfield ";
		return super.ExecuteQuery(hql, className + "-->selectByJournalId");
	}
	public boolean saveResearchField(ResearchField researchField){
		return super.updateObject(researchField,className+"-->saveResearchField(ResearchField researchField)");
	}
	public boolean deleteResearchField(ResearchField researchField){
		return super.deleteObject(researchField,className+"-->deleteResearchField(ResearchField researchField)")==null?false:true;
	}
	public boolean deleteResearchFieldById(Long pid){
		String hql="delete from  ResearchField where pid=:pid";
		Map<String,Object> map=new HashMap<String, Object>();
		map.put("pid", pid);
		return super.ExecuteNonQuery(hql, map,className+"-->deleteResearchFieldById(Long pid)");
	}

	
}
